#include "header/pyramid_entrance_objects.h"
#include "header/pyramid_torch.h"

OSG_USING_NAMESPACE

NodePtr createEntranceObjects() {
	
	Matrix m;
	
	
	//entranceTorch1
	NodePtr entranceTorch1 = createTorch();
	//Transformation
	TransformPtr tentranceTorch1 = Transform::create();
	beginEditCP(tentranceTorch1, Transform::MatrixFieldMask);
		m.setIdentity();
		m.setTranslate(4.5, 42, 200);
		tentranceTorch1->setMatrix(m);
	endEditCP(tentranceTorch1, Transform::MatrixFieldMask);
	
	NodePtr entranceTorch1Trans = Node::create();
	beginEditCP(entranceTorch1Trans, Node::CoreFieldMask | Node::ChildrenFieldMask);
		entranceTorch1Trans->setCore(tentranceTorch1);
		entranceTorch1Trans->addChild(entranceTorch1);
	endEditCP(entranceTorch1Trans, Node::CoreFieldMask | Node::ChildrenFieldMask);
	
	//entranceTorch2
	NodePtr entranceTorch2 = createTorch();
	//Transformation
	TransformPtr tentranceTorch2 = Transform::create();
	beginEditCP(tentranceTorch2, Transform::MatrixFieldMask);
		m.setIdentity();
		m.setTranslate(65.5, 42, 400);
		m.setRotate(Quaternion(Vec3f(0,1,0), +3.14159));
		tentranceTorch2->setMatrix(m);
	endEditCP(tentranceTorch2, Transform::MatrixFieldMask);
	
	NodePtr entranceTorch2Trans = Node::create();
	beginEditCP(entranceTorch2Trans, Node::CoreFieldMask | Node::ChildrenFieldMask);
		entranceTorch2Trans->setCore(tentranceTorch2);
		entranceTorch2Trans->addChild(entranceTorch2);
	endEditCP(entranceTorch2Trans, Node::CoreFieldMask | Node::ChildrenFieldMask);
	
	
	// *********** ShadowDummy ***********
	NodePtr shadowDummy = makeSphere(2,2);
	
	TransformPtr tshadowDummy = Transform::create();
	beginEditCP(tshadowDummy, Transform::MatrixFieldMask);
		m.setIdentity();
		m.setTranslate(0, -100, 1200);		// hide me
		tshadowDummy->setMatrix(m);
	endEditCP(tshadowDummy, Transform::MatrixFieldMask);
	
	NodePtr shadowDummyTrans = Node::create();
	beginEditCP(shadowDummyTrans, Node::CoreFieldMask | Node::ChildrenFieldMask);
		shadowDummyTrans->setCore(tshadowDummy);
		shadowDummyTrans->addChild(shadowDummy);
	endEditCP(shadowDummyTrans, Node::CoreFieldMask | Node::ChildrenFieldMask);
	
	
	// Erstellen eines Knotens
	NodePtr entranceObjects = Node::create();
	beginEditCP(entranceObjects, Node::CoreFieldMask);
	{
		entranceObjects->setCore(Group::create());
		entranceObjects->addChild(entranceTorch1Trans);
		entranceObjects->addChild(entranceTorch2Trans);
		entranceObjects->addChild(shadowDummyTrans);
	}
	endEditCP (entranceObjects, Node::CoreFieldMask);
	
	return entranceObjects;
}

